package me.wangshier.jms.taco.message.queue;

import java.util.concurrent.LinkedBlockingDeque;

/**
 * @Author: tongqianwen
 * @Date: 2024/12/17
 */
public class Consumer implements Runnable {
    private LinkedBlockingDeque<String> queue;

    public Consumer(LinkedBlockingDeque<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        String threadName = Thread.currentThread().getName();
        while (true) {
            try {
                String data = queue.take();
                System.out.println(threadName + " process data: " + data);
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
